﻿using System.ComponentModel;
using JBeamLibrary.Events;
using JBeamLibrary.VehicleParts.Elements;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JBeamLibrary.VehicleParts.Interfaces;

namespace JBeamLibrary.VehicleParts.Collections
{
    public class PropCollection : Collection<Prop>, IVehicleGroupCollection<Prop>
    {
        #region Fields

        public event ElementPropertyChangedEventHandler ElementPropertyChanged;

        #endregion

        #region CTORs

        /// <summary>Creates a new prop collection</summary>
        public PropCollection() { }

        /// <summary>Creates a new prop collection</summary>
        /// <param name="beams"></param>
        public PropCollection(IEnumerable<Prop> props)
        {
            AddRange(props);
        }

        #endregion

        #region Methods

        public new void Add(Prop prop)
        {
            base.Add(prop);

            prop.PropertyChanged += (s, e) =>
            {
                if (ElementPropertyChanged != null)
                    ElementPropertyChanged(s, e);
            };
        }

        public void Add(string func, string mesh, string idRef, string idX, string idY)
        {
            Add(new Prop(func, mesh, idRef, idX, idY));
        }

        public void AddRange(IEnumerable<Prop> props)
        {
            foreach (var prop in props)
                Add(prop);
        }

        public new void Remove(Prop element)
        {
            base.Remove(element);
        }

        #endregion
    }
}
